package com.example.demo1.action;

import com.example.demo1.model.Flight;
import com.example.demo1.model.Message;
import com.example.demo1.model.Order;
import com.example.demo1.model.User;
import com.example.demo1.service.FlightService;
import com.example.demo1.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/message")
public class MessageAction {
    //杨德旭10.18
    @Autowired
    MessageService messageService;

    @RequestMapping("/getUserMessage")
    public String getUserMessage(Model model, HttpSession session) {
        User user=(User)session.getAttribute("USER_SESSION");
        List<Message> messageList=messageService.getUserMessage(user);
        model.addAttribute("messageList",messageList);
        return "/userMessage";
    }

    @RequestMapping("/dealMessage")
    public String dealMessage(Model model, HttpSession session,Message message) {
        messageService.dealMessage(message);
        User user=(User)session.getAttribute("USER_SESSION");
        List<Message> messageList=messageService.getUserMessage(user);
        model.addAttribute("messageList",messageList);
        return "/userMessage";
    }

}
